<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h3>v-model修饰符</h3>

      <!-- lazy修饰符是需要当输入框失去焦点的时候才会触发 -->
      <input type="text" v-model.lazy="value" />
      <p>value: {{ value }}</p>

      <!-- 尝试将变量转成数字类型 -->
      <input type="text" v-model.number="num" />
      <p>num: {{ num }} - {{ typeof num }}</p>

      <!-- trim用于去除首尾空格 -->
      <input type="text" v-model.trim="text" />
      <p>text: {{ text }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            value: "",
            num: 1,
            text: "",
          };
        },
        methods: {
          fn() {
            console.log(this.text);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
